﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using telWebBrowserNet.Lib.TeleDLL.Model;

namespace telWebBrowserNet.Lib.TeleDLL
{
    public class BoxCommand
    {
        public static string check = "adusun<CurrentStation?checksum:000000>end";//心跳
        //public static string callCommand = "adusun<CallOutNumber:" + phone + ";checksum:000000>end";
        public static string deCallCommand = "adusun<HookOn;checksum:000000>end";//挂电话
        public static string modeHave = "adusun<AdsMode:Attended;checksum:000000>end";//有人值守
        public static string info = "测试调用成功";
        //拨打电话
        public static string callCommand(string phone)
        {
            return "adusun<CallOutNumber:" + phone + ";checksum:000000>end";
        }

        public static ReadModel CheckStatus()
        {
            WriteModel writeModel = new WriteModel();
            writeModel.PDeviceHandle = TeleHelper.PDeviceHandle;
            writeModel.addCommand("CurrentStation?", "");
            /*    writeModel.addCommand("CallOutNumber","10086");*/
            int second = DateTime.Now.Second;
            String checksum = "00000" + (second % 10);
            writeModel.addCommand("checksum", checksum);
            ReadModel readModel = TeleHelper.Execute(writeModel);
            return readModel;
        }

        public static ReadModel HookOff()
        {
            WriteModel writeModel = new WriteModel();
            writeModel.PDeviceHandle = TeleHelper.PDeviceHandle;
            writeModel.addCommand("HookOff", "");
            /*    writeModel.addCommand("CallOutNumber","10086");*/
            int second = DateTime.Now.Second;
            String checksum = "00000" + (second % 10);
            writeModel.addCommand("checksum", checksum);
            ReadModel readModel = TeleHelper.Execute(writeModel);
            return readModel;
        }

        public static void test1()
        {
            WriteModel writeModel = new WriteModel();
            writeModel.PDeviceHandle = TeleHelper.PDeviceHandle;
            writeModel.addCommand("CurrentStation?", "");
            /*    writeModel.addCommand("CallOutNumber","10086");*/
            int second = DateTime.Now.Second;
            String checksum = "00000" + (second % 10);
            writeModel.addCommand("checksum", checksum);
            ReadModel readModel = TeleHelper.Execute(writeModel);
            if (readModel.Code != 0)
            {
                //出错流程
                if (readModel.Code == 1)
                {
                    Console.WriteLine("TeleWriteCode" + readModel.TeleWriteCode);
                    return;
                }
                if (readModel.Code == 2)
                {
                    Console.WriteLine("TeleReadCode" + readModel.TeleReadCode);
                    return;
                }
                return;
            }
            Console.WriteLine("checksum" + readModel.Checksum);
        }
    }
}
